package com.irain.pp.tool.redis.spring;

import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 * @author WangYanPeng
 * @date 2017/11/14 16:36
 */
public class PpRedisTemplate extends RedisTemplate<String,Object> {

    public PpRedisTemplate(RedisConnectionFactory connectionFactory){
        setConnectionFactory(connectionFactory);
        //使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
        setValueSerializer(new PpJackson2JsonRedisSerializer());
        //使用StringRedisSerializer来序列化和反序列化redis的key值
        setKeySerializer(new StringRedisSerializer());
        afterPropertiesSet();
    }
}
